#pragma once

#include <vector>
#include <memory>
#include <string>
#include "common_ptr.h"

class FnvHash
{
public:
  static long BASIC;
  static long PRIME;

public:
  static long fnv1a_64(string_ptr input);
  static long fnv1a_64(std::stringbuf input);

  static long fnv1a_64(string_ptr input, int offset, int end);

  static long fnv1a_64(char *input, int offset, int end);

  static long fnv1a_64(char *chars);

  /**
   * lower and normalized and fnv_1a_64
   *
   * @param name
   * @return
   */
  // static long hashCode64(string_ptr  name);
  static long hashCode64(string_ptr name);
  /**
   * normalized and lower and fnv1a_64_hash
   *
   * @param owner
   * @param name
   * @return
   */
  static long hashCode64(string_ptr owner, string_ptr name);
  static long hashCode64(string_ptr key, int offset, int end);
  // static long hashCode64(long basic, string_ptr  name);
  static long hashCode64(long basic, string_ptr name);
  static long hashCode64(long basic, string_ptr key, int offset, int end);

  static long fnv1a_64_lower(std::string key);
  static long fnv1a_64_lower(string_ptr key);
  // static long fnv1a_64_lower(string_ptr key);
  // static long fnv1a_64_lower(std::stringbuf key) ;

  static long fnv1a_64_lower(long basic, string_ptr key);

  static long fnv_32_lower(string_ptr key);

  static std::shared_ptr<std::vector<long>> fnv1a_64_lower(std::shared_ptr<std::vector<string_ptr>> strings, bool sort);
  static void fnv1a_64_lower(std::shared_ptr<std::vector<string_ptr>> strings, std::shared_ptr<std::vector<long>> out, bool sort);
  // static long* fnv1a_64_lower(string_ptr  strings[], bool sort) ;

  class Constants
  {
    // public:
    //   Constants();

  public:
    static long HIGH_PRIORITY;
    static long DISTINCTROW;
    static long STRAIGHT;
    static long STRAIGHT_JOIN;
    static long SQL_SMALL_RESULT;
    static long SQL_BIG_RESULT;
    static long SQL_BUFFER_RESULT;
    static long CACHE;
    static long SQL_CACHE;
    static long SQL_NO_CACHE;
    static long SQL_CALC_FOUND_ROWS;
    static long TOP;
    static long OUTFILE;
    static long SETS;
    static long REGEXP;
    static long RLIKE;
    static long USING;
    static long MATCHED;
    static long IGNORE;
    static long FORCE;
    static long CROSS;
    static long NATURAL;
    static long APPLY;
    static long CONNECT;
    static long START;
    static long BTREE;
    static long HASH;
    static long DUPLICATE;
    static long LIST;
    static long NO_WAIT;
    static long WAIT;
    static long NOWAIT;
    static long ERRORS;
    static long VALUE;
    static long OBJECT;
    static long NEXT;
    static long NEXTVAL;
    static long CURRVAL;
    static long PREVVAL;
    static long PREVIOUS;
    static long LOW_PRIORITY;
    static long COMMIT_ON_SUCCESS;
    static long ROLLBACK_ON_FAIL;
    static long QUEUE_ON_PK;
    static long TARGET_AFFECT_ROW;
    static long COLLATE;
    static long BOOLEAN;
    static long SMALLINT;
    static long SHORT;
    static long TINY;
    static long TINYINT;
    static long CHARSET;
    static long SEMI;
    static long ANTI;
    static long PRIOR;
    static long NOCYCLE;
    static long CYCLE;
    static long CONNECT_BY_ROOT;

    static long DATE;
    static long GSON;
    static long NEW;
    static long NEWDATE;
    static long DATETIME;
    static long TIME;
    static long ZONE;
    static long JSON;
    static long TIMESTAMP;
    static long TIMESTAMPTZ;
    static long CLOB;
    static long NCLOB;
    static long TINYBLOB;
    static long BLOB;
    static long XMLTYPE;
    static long BFILE;
    static long UROWID;
    static long ROWID;
    static long REF;
    static long INTEGER;
    static long INT;
    static long INT24;
    static long BINARY_FLOAT;
    static long BINARY_DOUBLE;
    static long FLOAT;
    static long REAL;
    static long NUMBER;
    static long NUMERIC;
    static long DEC;
    static long DECIMAL;

    static long CURRENT;
    static long COUNT;
    static long ROW_NUMBER;
    static long FIRST_VALUE;
    static long LAST_VALUE;
    static long WM_CONCAT;
    static long AVG;
    static long MAX;
    static long MIN;
    static long STDDEV;
    static long RANK;
    static long SUM;
    static long ARBITRARY;
    static long GROUP_CONCAT;
    static long CONVERT_TZ;
    static long DEDUPLICATION;
    static long CONVERT;
    static long CHAR;
    static long ENUM;
    static long STRING;
    static long VARCHAR;
    static long VARCHAR2;
    static long NCHAR;
    static long NVARCHAR;
    static long NVARCHAR2;
    static long NCHAR_VARYING;
    static long VARBINARY;
    static long TINYTEXT;
    static long TEXT;
    static long MEDIUMTEXT;
    static long LONGTEXT;
    static long TRIM;
    static long LEADING;

    static long BOTH;
    static long TRAILING;
    static long MOD;
    static long MATCH;
    static long AGAINST;
    static long EXTRACT;
    static long POLYGON;
    static long CIRCLE;
    static long LSEG;
    static long POINT;
    static long BOX;
    static long MACADDR;
    static long INET;
    static long CIDR;
    static long POSITION;
    static long DUAL;
    static long LEVEL;
    static long CONNECT_BY_ISCYCLE;
    static long CURRENT_TIMESTAMP;
    static long LOCALTIMESTAMP;
    static long LOCALTIME;
    static long SESSIONTIMEZONE;
    static long DBTIMEZONE;
    static long CURRENT_DATE;
    static long CURRENT_TIME;
    static long CURTIME;
    static long CURRENT_USER;
    static long XFALSE;
    static long XTRUE;
    static long LESS;
    static long MAXVALUE;
    static long OFFSET;
    static long LIMIT;
    static long RAW;
    static long LONG_RAW;
    static long LONG;
    static long BYTE;
    static long ROWNUM;
    static long SYSDATE;
    static long NOW;
    static long ADDTIME;
    static long SUBTIME;
    static long TIMEDIFF;
    static long SQLCODE;
    static long PRECISION;
    static long DOUBLE;
    static long DOUBLE_PRECISION;
    static long WITHOUT;
    static long BITAND;

    static long DEFINER;
    static long EVENT;
    static long RESOURCE;
    static long RESOURCES;
    static long FILE;
    static long JAR;
    static long PY;
    static long ARCHIVE;
    static long DETERMINISTIC;
    static long CONTAINS;
    static long SQL;
    static long CALL;
    static long CHARACTER;
    static long UNNEST;

    static long VALIDATE;
    static long NOVALIDATE;
    static long SIMILAR;
    static long CASCADE;
    static long RELY;
    static long NORELY;
    static long ROW;
    static long ROWS;
    static long RANGE;
    static long PRECEDING;
    static long FOLLOWING;
    static long UNBOUNDED;
    static long SIBLINGS;
    static long RESPECT;
    static long NULLS;
    static long FIRST;
    static long LAST;
    static long AUTO_INCREMENT;
    static long STORAGE;
    static long STORED;
    static long VIRTUAL;
    static long SIGNED;
    static long UNSIGNED;
    static long ZEROFILL;
    static long GLOBAL;
    static long LOCAL;
    static long TEMPORARY;
    static long NONCLUSTERED;
    static long SESSION;
    static long NAMES;
    static long PARTIAL;
    static long SIMPLE;
    static long RESTRICT;
    static long ON;
    static long ACTION;
    static long SEPARATOR;
    static long DATA;
    static long MIGRATE;
    static long MAX_ROWS;
    static long MIN_ROWS;
    static long PACK_KEYS;
    static long ENGINE;
    static long SKIP;
    static long RECURSIVE;
    static long ROLLUP;
    static long CUBE;

    static long YEAR;
    static long QUARTER;
    static long MONTH;
    static long WEEK;
    static long WEEKDAY;
    static long WEEKOFYEAR;
    static long YEARWEEK;
    static long YEAR_OF_WEEK;
    static long YOW;
    static long YEARMONTH;
    static long TO_TIMESTAMP;
    static long DAY;
    static long DAYOFMONTH;
    static long DAYOFWEEK;
    static long DATE_TRUNC;
    static long DAYOFYEAR;
    static long MONTH_BETWEEN;
    static long TIMESTAMPADD;
    static long HOUR;
    static long MINUTE;
    static long SECOND;
    static long MICROSECOND;
    static long CURDATE;
    static long CUR_DATE;
    static long DATE_DIFF;

    static long SECONDS;
    static long MINUTES;
    static long HOURS;
    static long DAYS;
    static long MONTHS;
    static long YEARS;

    static long BEFORE;
    static long AFTER;
    static long INSTEAD;

    static long DEFERRABLE;
    static long AS;
    static long DELAYED;
    static long GO;
    static long WAITFOR;
    static long EXEC;
    static long EXECUTE;

    static long SOURCE;

    static long STAR;

    static long TO_CHAR;
    static long UNIX_TIMESTAMP;
    static long FROM_UNIXTIME;
    static long TO_UNIXTIME;
    static long SYS_GUID;
    static long LAST_DAY;
    static long MAKEDATE;
    static long ASCII;
    static long DAYNAME;

    static long STATISTICS;
    static long TRANSACTION;
    static long OFF;
    static long IDENTITY_INSERT;
    static long PASSWORD;
    static long SOCKET;
    static long OWNER;
    static long PORT;
    static long PUBLIC;
    static long SYNONYM;
    static long MATERIALIZED;
    static long BITMAP;
    static long LABEL;
    static long PACKAGE;
    static long PACKAGES;
    static long TRUNC;
    static long SYSTIMESTAMP;
    static long TYPE;
    static long RECORD;
    static long MAP;
    static long MAPJOIN;
    static long MAPPED;
    static long MAPPING;
    static long COLPROPERTIES;
    static long ONLY;
    static long MEMBER;
    static long STATIC;
    static long FINAL;
    static long INSTANTIABLE;
    static long UNSUPPORTED;
    static long VARRAY;
    static long WRAPPED;
    static long AUTHID;
    static long UNDER;
    static long USERENV;
    static long NUMTODSINTERVAL;

    static long LATERAL;
    static long NONE;
    static long PARTITIONING;
    static long VALIDPROC;
    static long COMPRESS;
    static long YES;
    static long WMSYS;

    static long DEPTH;
    static long BREADTH;

    static long SCHEDULE;
    static long COMPLETION;
    static long RENAME;
    static long AT;
    static long LANGUAGE;
    static long LOGFILE;
    static long LOG;
    static long INITIAL_SIZE;
    static long MAX_SIZE;
    static long NODEGROUP;
    static long EXTENT_SIZE;
    static long AUTOEXTEND_SIZE;
    static long FILE_BLOCK_SIZE;
    static long BLOCK_SIZE;
    static long REPLICA_NUM;
    static long TABLET_SIZE;
    static long PCTFREE;
    static long USE_BLOOM_FILTER;
    static long SERVER;
    static long HOST;
    static long ADD;
    static long REMOVE;
    static long MOVE;
    static long ALGORITHM;
    static long LINEAR;
    static long EVERY;
    static long STARTS;
    static long ENDS;
    static long BINARY;
    static long GEOMETRY;
    static long ISOPEN;
    static long CONFLICT;
    static long NOTHING;
    static long COMMIT;
    static long DESCRIBE;
    static long SQLXML;
    static long BIT;
    static long LONGBLOB;

    static long RS;
    static long RR;
    static long CS;
    static long UR;

    static long INT4;
    static long VARBIT;
    static long DECODE;
    static long IF;
    static long FUNCTION;
    static long EXTERNAL;
    static long SORTED;
    static long CLUSTERED;
    static long LIFECYCLE;
    static long LOCATION;
    static long PARTITIONS;
    static long FORMAT;
    static long ENCODE;

    static long SELECT;
    static long DELETE;
    static long UPDATE;
    static long INSERT;
    static long REPLACE;
    static long TRUNCATE;
    static long CREATE;
    static long MERGE;
    static long SHOW;
    static long ALTER;
    static long DESC;
    static long SET;
    static long KILL;
    static long MSCK;
    static long USE;
    static long ROLLBACK;
    static long GRANT;
    static long REVOKE;
    static long DROP;
    static long USER;

    static long USAGE;
    static long PCTUSED;
    static long OPAQUE;
    static long INHERITS;
    static long DELIMITED;
    static long ARRAY;
    static long SCALAR;
    static long STRUCT;
    static long TABLE;
    static long UNIONTYPE;

    static long TDDL;
    static long CONCURRENTLY;
    static long TABLES;
    static long ROLES;
    static long NOCACHE;
    static long NOPARALLEL;
    static long EXIST;
    static long EXISTS;
    static long SOUNDS;
    static long TBLPROPERTIES;
    static long TABLEGROUP;
    static long TABLEGROUPS;
    static long DIMENSION;
    static long OPTIONS;
    static long OPTIMIZER;

    static long FULLTEXT;
    static long SPATIAL;

    static long SUBPARTITION_AVAILABLE_PARTITION_NUM;
    static long EXTRA;
    static long DATABASES;
    static long COLUMNS;
    static long PROCESS;
    static long PROCESSLIST;
    static long MPP;
    static long SERDE;
    static long SORT;
    static long ZORDER;
    static long FIELDS;
    static long COLLECTION;
    static long SKEWED;
    static long SYMBOL;
    static long LOAD;
    static long VIEWS;
    static long SUBSTR;
    static long TO_BASE64;
    static long REGEXP_SUBSTR;
    static long REGEXP_COUNT;
    static long REGEXP_EXTRACT;
    static long REGEXP_EXTRACT_ALL;
    static long REGEXP_LIKE;
    static long REGEXP_REPLACE;
    static long REGEXP_SPLIT;
    static long CONCAT;
    static long LCASE;
    static long UCASE;
    static long LOWER;
    static long UPPER;
    static long LENGTH;
    static long LOCATE;
    static long UDF_SYS_ROWCOUNT;
    static long CHAR_LENGTH;
    static long CHARACTER_LENGTH;
    static long SUBSTRING;
    static long SUBSTRING_INDEX;
    static long LEFT;
    static long RIGHT;
    static long RTRIM;
    static long LEN;
    static long GREAST;
    static long LEAST;
    static long IFNULL;
    static long NULLIF;
    static long GREATEST;
    static long COALESCE;
    static long ISNULL;
    static long NVL;
    static long NVL2;
    static long TO_DATE;
    static long DATEADD;
    static long DATE_ADD;
    static long ADDDATE;
    static long DATE_SUB;
    static long SUBDATE;
    static long DATE_PARSE;
    static long STR_TO_DATE;
    static long CLOTHES_FEATURE_EXTRACT_V1;
    static long CLOTHES_ATTRIBUTE_EXTRACT_V1;

    static long GENERIC_FEATURE_EXTRACT_V1;
    static long FACE_FEATURE_EXTRACT_V1;
    static long TEXT_FEATURE_EXTRACT_V1;

    static long JSON_TABLE;
    static long JSON_EXTRACT;
    static long JSON_EXTRACT_SCALAR;
    static long JSON_ARRAY_GET;
    static long ADD_MONTHS;
    static long ABS;
    static long ACOS;
    static long ASIN;
    static long ATAN;
    static long ATAN2;
    static long COS;
    static long FLOOR;
    static long CEIL;
    static long SQRT;
    static long LEAD;
    static long LAG;
    static long CEILING;
    static long POWER;
    static long EXP;
    static long LN;
    static long LOG10;
    static long INTERVAL;
    static long FROM_DAYS;
    static long TO_DAYS;

    static long BIGINT;
    static long LONGLONG;
    static long DISCARD;
    static long EXCHANGE;
    static long ROLE;
    static long OVERWRITE;
    static long NO;
    static long CATALOG;
    static long CATALOGS;
    static long FUNCTIONS;
    static long SCHEMAS;
    static long CHANGE;
    static long MODIFY;
    static long BEGIN;
    static long PATH;
    static long ENCRYPTION;
    static long COMPRESSION;
    static long KEY_BLOCK_SIZE;
    static long CHECKSUM;
    static long CONNECTION;
    static long DATASOURCES;
    static long NODE;
    static long HELP;
    static long BROADCASTS;
    static long MASTER;
    static long SLAVE;
    static long SQL_DELAY_CUTOFF;
    static long SOCKET_TIMEOUT;
    static long FORBID_EXECUTE_DML_ALL;
    static long SCAN;
    static long NOLOGFILE;
    static long NOBADFILE;
    static long TERMINATED;
    static long LTRIM;
    static long MISSING;
    static long SUBPARTITION;
    static long SUBPARTITIONS;
    static long GENERATED;
    static long ALWAYS;
    static long VISIBLE;
    static long INCLUDING;
    static long EXCLUDE;
    static long EXCLUDING;
    static long ROUTINE;
    static long IDENTIFIED;
    static long DELIMITER;
    static long UNKNOWN;
    static long WEIGHT_STRING;
    static long REVERSE;
    static long DATE_FORMAT;
    static long DAY_OF_WEEK;
    static long DATEDIFF;
    static long GET_FORMAT;
    static long TIMESTAMPDIFF;
    static long MONTHNAME;
    static long PERIOD_ADD;
    static long PERIOD_DIFF;
    static long ROUND;
    static long DBPARTITION;
    static long TBPARTITION;
    static long EXTPARTITION;
    static long STARTWITH;
    static long TBPARTITIONS;
    static long DBPARTITIONS;
    static long PARTITIONED;
    static long PARALLEL;
    static long ALLOW;
    static long DISALLOW;
    static long PIVOT;
    static long MODEL;
    static long KEEP;
    static long REFERENCE;
    static long RETURN;
    static long RETURNS;
    static long ROWTYPE;
    static long WINDOW;
    static long QUALIFY;
    static long MULTIVALUE;
    static long OPTIONALLY;
    static long ENCLOSED;
    static long ESCAPED;
    static long ESCAPE;
    static long LINES;
    static long STARTING;
    static long DISTRIBUTE;
    static long DISTRIBUTED;
    static long CLUSTER;
    static long RUNNING;
    static long CLUSTERING;
    static long PCTVERSION;
    static long IDENTITY;
    static long INCREMENT;
    static long MINVALUE;
    static long ANN;
    static long ANN_DISTANCE;
    static long SUPPLEMENTAL;
    static long SUBSTITUTABLE;
    static long BASICFILE;
    static long IN_MEMORY_METADATA;
    static long CURSOR_SPECIFIC_SEGMENT;
    static long DEFER;
    static long UNDO_LOG_LIMIT;
    static long DBPROPERTIES;
    static long ANNINDEX;
    static long RTTYPE;
    static long DISTANCE;
    static long IDXPROPERTIES;
    static long RECOVER;
    static long BACKUP;
    static long RESTORE;
    static long EXSTORE;
    static long UNDO;
    static long NOSCAN;
    static long EXTENDED;
    static long FORMATTED;
    static long DEPENDENCY;
    static long AUTHORIZATION;
    static long ANALYZE;
    static long EXPORT;
    static long IMPORT;
    static long TABLESAMPLE;
    static long BUCKET;
    static long BUCKETS;
    static long UNARCHIVE;
    static long SEQUENCES;
    static long OUTLINE;
    static long ORD;
    static long SPACE;
    static long REPEAT;
    static long SLOW;
    static long PLAN;
    static long PLANCACHE;
    static long RECYCLEBIN;
    static long PURGE;
    static long FLASHBACK;
    static long INPUTFORMAT;
    static long OUTPUTFORMAT;
    static long DUMP;
    static long BROADCAST;
    static long GROUP;
    static long GROUPING;
    static long WITH;
    static long FROM;
    static long WHO;
    static long WHOAMI;
    static long GRANTS;
    static long STATISTIC;
    static long STATISTIC_LIST;
    static long STATUS;
    static long FULL;
    static long STATS;
    static long OUTLINES;
    static long VERSION;
    static long CONFIG;
    static long USERS;
    static long PHYSICAL_PROCESSLIST;
    static long PHYSICAL;
    static long DISTANCEMEASURE;
    static long UNIT;
    static long DB;
    static long STEP;
    static long HEX;
    static long UNHEX;
    static long POLICY;
    static long QUERY_TASK;
    static long UUID;
    static long PCTTHRESHOLD;
    static long UNUSABLE;
    static long FILTER;
    static long BIT_COUNT;
    static long STDDEV_SAMP;
    static long PERCENT_RANK;
    static long DENSE_RANK;
    static long CUME_DIST;
    static long CARDINALITY;
    static long TRY_CAST;
    static long COVERING;

    static long CHARFILTER;
    static long CHARFILTERS;
    static long TOKENIZER;
    static long TOKENIZERS;
    static long TOKENFILTER;
    static long TOKENFILTERS;
    static long ANALYZER;
    static long ANALYZERS;
    static long DICTIONARY;
    static long DICTIONARIES;
    static long QUERY;
    static long META;
    static long TRY;
    static long D;
    static long T;
    static long TS;
    static long FN;
    static long COPY;
    static long CREDENTIALS;
    static long ACCESS_KEY_ID;
    static long ACCESS_KEY_SECRET;
    static long BERNOULLI;
    static long SYSTEM;
    static long SYNC;
    static long INIT;
    static long BD;
    static long FORMAT_DATETIME;
    static long WITHIN;
    static long RULE;
    static long EXPLAIN;
    static long ISOLATION;
    static long READ;
    static long UNCOMMITTED;
    static long COMMITTED;
    static long REPEATABLE;
    static long SERIALIZABLE;

    static long _LATIN1;
    static long _GBK;
    static long _BIG5;
    static long _UTF8;
    static long _UTF8MB4;
    static long _UTF16;
    static long _UTF16LE;
    static long _UTF32;
    static long _UCS2;
    static long _UJIS;
    static long X;
    static long TRANSFORM;
    static long NESTED;
    static long RESTART;

    static long ASOF;
    static long JSON_SET;
    static long JSONB_SET;

    static long TUNNEL;
    static long DOWNLOAD;
    static long UPLOAD;
    static long CLONE;
    static long INSTALL;
    static long UNLOAD;

    static long AGGREGATE;
    static long UNIQUE;
    static long PRIMARY;
    static long THAN;
    static long PROPERTIES;
  };
};
